#include<bits/stdc++.h>

using namespace std;
class Solution {
public:
    double diff(int x,int y){
        return (double)(x+1)/(y+1)-(double)x/y;
    }
    double maxAverageRatio(vector<vector<int>>& classes, int extraStudents) {
        priority_queue<tuple<double,int,int>> q;
        double ans=0;
        for(auto &c: classes){
            int x=c[0],y=c[1];
            ans+=(double)x/y;
            q.emplace(diff(x,y),x,y);
        }
        for(int i=0;i<extraStudents;i++){
            auto [c,x,y]=q.top();
            q.pop();
            ans+=c;
            q.emplace(diff(x+1,y+1),x+1,y+1);
        }
        return ans/classes.size();
    }
};

int main(){




    return 0;
}